package com.geek.util;

import sun.misc.Unsafe;

import java.lang.reflect.Field;

public class UnSafeUtil {

	private volatile static Unsafe instance = null;

	private UnSafeUtil(){}

	public static Unsafe getInstance(){
		if(instance == null){
			synchronized (UnSafeUtil.class){
				if(instance == null){
					try {
						Field field = Unsafe.class.getDeclaredField("theUnsafe");
						field.setAccessible(true);
						instance = (Unsafe) field.get(null);
					}catch (Exception e){
						e.printStackTrace();
					}
				}
			}
		}
		return instance;
	}
}
